package com.hankol.newretail.viewmodel

import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel
import com.baselibrary.bean.ReceiveAddressBean
import com.hankol.newretail.respository.NewReatilRequestManager

/** 地址相关
 * @author: merbng
 * @time: 2022/8/5 9:56
 * @description:
 */
class AddressAboutViewModel : ViewModel() {
    var addressDataLD: MutableLiveData<List<ReceiveAddressBean>> = MutableLiveData()
    var addAddressLD: MutableLiveData<ReceiveAddressBean> = MutableLiveData()
    var editAddressLD: MutableLiveData<Any> = MutableLiveData()
    var deleteOrSetDefAddressLD: MutableLiveData<Any> = MutableLiveData()

    // 地址列表
    fun requestAddressList() {
        NewReatilRequestManager.getInstance().requestAddressList(addressDataLD)
    }

    // 新增 地址
    fun requestNewAddAddressList(name: String, phone: String, areaFirst: String, areaSecond: String, areaThree: String, address: String, def: Int) {
        NewReatilRequestManager.getInstance().requestNewAddAddressList(name, phone, areaFirst, areaSecond, areaThree, address, def, addAddressLD)
    }

    // 编辑 地址
    fun requestSaveEditAddressList(id: String,name: String, phone: String, areaFirst: String, areaSecond: String, areaThree: String, address: String, def: Int) {
        NewReatilRequestManager.getInstance().requestSaveEditAddressList(id,name, phone, areaFirst, areaSecond, areaThree, address, def, editAddressLD)
    }

    // 删除 地址
    fun requestDeleteAddress(id: String) {
        NewReatilRequestManager.getInstance().requestDeleteAddress(id, deleteOrSetDefAddressLD)
    }

    // 设置默认地址 地址
    fun requestSetDefAddress(id: String) {
        NewReatilRequestManager.getInstance().requestSetDefAddress(id, deleteOrSetDefAddressLD)
    }
}